package com.travel.system.controller;


import com.travel.system.common.result.ResultInfo;
import com.travel.system.entity.UserInfo;
import com.travel.system.service.UserInfoService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/tourism/www/user")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "用户相关接口")
@CrossOrigin
public class UserInfoController {

    private final UserInfoService userInfoService;

    @PostMapping("/register")
    ResultInfo<String> register(@RequestBody UserInfo userInfo) {
        return userInfoService.register(userInfo);
    }

    @GetMapping("/login")
    ResultInfo<String> login(@RequestParam String username, @RequestParam String password) {
        return userInfoService.login(username, password);
    }

    @GetMapping("/updatePassword")
    ResultInfo<String> updatePassword(@RequestParam String username, @RequestParam String newPwd, @RequestParam String oldPwd) {
        return userInfoService.updatePassword(username, newPwd, oldPwd);
    }

}
